<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function Father (uname, age) {
            this.uname = uname
            this.age = age
            // console.log(this);
            // this.money = function () {
            //     console.log('我赚了一个小目标');
            // }
        }
        Father.prototype.money = function () {
            console.log('我赚了一个小目标');
        }


        function Son (uname, age) {
            Father.call(this, uname, age)
        }

        //把Father的原型对象给了Son(覆盖)
        // Son.prototype = Father.prototype

        //把Father的实例化对象给了Son(覆盖)
        // Son.prototype = new Father()

        Son.prototype.__proto__ = Father.prototype

        //将Son.prototype的constructor属性指回Son构造函数
        // Son.prototype.constructor = Son

        //给Son.prototype添加新的方法
        Son.prototype.exam = function () {
            console.log('我今天考了100分');
        }

        const son = new Son('ls', 18)
        const father = new Father('zs', 40)
        // console.log(uname);
        console.log(son);
        son.money()
        son.exam()
        father.exam()
    </script>
</body>

</html>